package com.ruoyi.labdata.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ruoyi.labdata.mapper.LabOrgThirdRelDictMapper;
import com.ruoyi.labdata.domain.LabOrgThirdRelDict;
import com.ruoyi.labdata.service.ILabOrgThirdRelDictService;

/**
 * 实验室安全字典Service业务层处理
 * 
 * @author winner pan
 * @date 2022-02-06
 */
@Service
public class LabOrgThirdRelDictServiceImpl implements ILabOrgThirdRelDictService 
{
    @Autowired
    private LabOrgThirdRelDictMapper labOrgThirdRelDictMapper;

    /**
     * 查询实验室安全字典
     * 
     * @param dictRelId 实验室安全字典ID
     * @return 实验室安全字典
     */
    @Override
    public LabOrgThirdRelDict selectLabOrgThirdRelDictById(Long dictRelId)
    {
        return labOrgThirdRelDictMapper.selectLabOrgThirdRelDictById(dictRelId);
    }

    /**
     * 查询实验室安全字典列表
     * 
     * @param labOrgThirdRelDict 实验室安全字典
     * @return 实验室安全字典
     */
    @Override
    public List<LabOrgThirdRelDict> selectLabOrgThirdRelDictList(LabOrgThirdRelDict labOrgThirdRelDict)
    {
        return labOrgThirdRelDictMapper.selectLabOrgThirdRelDictList(labOrgThirdRelDict);
    }

    /**
     * 新增实验室安全字典
     * 
     * @param labOrgThirdRelDict 实验室安全字典
     * @return 结果
     */
    @Override
    @Transactional
    public int insertLabOrgThirdRelDict(LabOrgThirdRelDict labOrgThirdRelDict)
    {	if(labOrgThirdRelDict.getDelDictRelIds()!=null && 
    		labOrgThirdRelDict.getDelDictRelIds().length>0){
    		this.deleteLabOrgThirdRelDictByIds(labOrgThirdRelDict.getDelDictRelIds());
    	}
    	if(labOrgThirdRelDict.getAddReldictValues()!=null &&
    			labOrgThirdRelDict.getAddReldictValues().length>0){
    		for(Long dictValue : labOrgThirdRelDict.getAddReldictValues()){
    			LabOrgThirdRelDict relDict = new LabOrgThirdRelDict();
    			relDict.setLabId(labOrgThirdRelDict.getLabId());
    			relDict.setLogotypeId(dictValue);
    			labOrgThirdRelDictMapper.insertLabOrgThirdRelDict(relDict);
    		}
    	}
        return 1;
    }

    /**
     * 修改实验室安全字典
     * 
     * @param labOrgThirdRelDict 实验室安全字典
     * @return 结果
     */
    @Override
    public int updateLabOrgThirdRelDict(LabOrgThirdRelDict labOrgThirdRelDict)
    {
        return labOrgThirdRelDictMapper.updateLabOrgThirdRelDict(labOrgThirdRelDict);
    }

    /**
     * 批量删除实验室安全字典
     * 
     * @param dictRelIds 需要删除的实验室安全字典ID
     * @return 结果
     */
    @Override
    public int deleteLabOrgThirdRelDictByIds(Long[] dictRelIds)
    {
        return labOrgThirdRelDictMapper.deleteLabOrgThirdRelDictByIds(dictRelIds);
    }

    /**
     * 删除实验室安全字典信息
     * 
     * @param dictRelId 实验室安全字典ID
     * @return 结果
     */
    @Override
    public int deleteLabOrgThirdRelDictById(Long dictRelId)
    {
        return labOrgThirdRelDictMapper.deleteLabOrgThirdRelDictById(dictRelId);
    }
}
